/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import dao.AirLineDAOException;
import dao.ReservaDAO;
import model.Reserva;
import business.UsuarioBusiness;
import dao.imp.ReservaDAOImpl;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import model.Usuario;

/**
 *
 * @author Neto
 */
public class ReservaBusiness {
    private Reserva reserva = new Reserva();
    private DataModel model;
    
    public Reserva getReserva(){
        return reserva;
    }
    public void setReserva(Reserva reserva){
        this.reserva = reserva;
    }
            
    public String salvarReserva() throws AirLineDAOException {
        ReservaDAO reservaCliente = new ReservaDAOImpl();
        reservaCliente.salvarReserva(reserva);
        return "reservaConcluida";
    }
    
    public String salvarReserva(String numVooReserva, String idUser) throws AirLineDAOException {
        ReservaDAO reservaCliente = new ReservaDAOImpl();
        reservaCliente.salvarReserva(numVooReserva, idUser);
        return "reservaConcluida";
    }
    
    public DataModel getTodasReservas() throws AirLineDAOException {
        ReservaDAO interfaceReserva = new ReservaDAOImpl();
        model = new ListDataModel(interfaceReserva.todasReservas());
        return model;
    }
    
    public DataModel getUserReservas(UsuarioBusiness usuario) throws AirLineDAOException {
        ReservaDAO interfaceReserva = new ReservaDAOImpl();
        model = new ListDataModel(interfaceReserva.reservaUser(usuario.getUsuario()));
        return model;
    }
    
}
